<?php
 include_once './common.php';
 $user=$_GET['user'];
 $sql="SELECT * FROM shoppingcart WHERE uid = '$user'";
 // echo $sql;die;
 $res=mysqli_query($link,$sql);
 $arr=array();
 if(mysqli_num_rows($res)>0){
	 // echo 11;
	 // var_dump($one=mysqli_fetch_assoc($res));die;
	 while($one=mysqli_fetch_assoc($res)){
		 $arr[]=$one;
	 }
	 
	 foreach($arr as $k=>$v){
		 $pid=$v['pid'];
		 $num=$v['num'];
		 $sql2="SELECT * FROM goods WHERE id='$pid'";
		 $res2=mysqli_query($link,$sql2);
		 while($one2=mysqli_fetch_assoc($res2)){
			  $arr2[]=$one2;
			  $arr2[$k]['num']=$arr[$k]['num'];
			  $arr2[$k]['cid']=$arr[$k]['cid'];	
		 }
	 }
	  echo json_encode($arr2);
 }else{
	  $arr['status'] == 0;
    echo json_encode($arr);
 }

?>
